package cn.edu.lcu.cs.javaweb.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/admin")
public class AdminServlet extends HttpServlet {

	public AdminServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Object currentUser = request.getSession().getAttribute("currentUser");
		if (currentUser == null) {
			// 未登录
			request.getRequestDispatcher("/login.jsp").forward(request, response);
		} else {
			// 已登录
			request.getRequestDispatcher("/WEB-INF/pages/admin.jsp").forward(request, response);
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	}

}
